﻿using ConsoleAppTestEf.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleAppTestEf.Services
{
    public class BlogService
    { 
        public void TestQuery()
        {
            using (var db = new BlogContext())
            {
                var query = db.Blogs
                    .Where(b => b.Rating > 3)
                    .OrderBy(b => b.Url)
                    .ToList();
            }
        }

        public void TestInsert()
        {
            using(var db=new BlogContext())
            {
                Blog blog = new Blog
                {
                    Url = "http://www.cnblogs.com",
                    Rating = 3
                };
                db.Blogs.Add(blog);
                db.SaveChanges();
            }
        }

        public void TestUpdate()
        {
            using(var db=new BlogContext())
            {
                
            }
        }
    }
}
